<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>禾米租房 - 用户注册</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" >
function post() {
	 
	 var xmlhttp;
	 if (window.XMLHttpRequest)
	   {// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	   }
	 else
	   {// code for IE6, IE5
	   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	   }

	 xmlhttp.open("get","check?username="+document.getElementById("name").value,true);
	 xmlhttp.send();
	 
	 xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	    document.getElementById("msg").innerHTML=xmlhttp.responseText;
	    }
	  }
	}
	
	function checkPwd() {
		var p1=password.value;
		var p2=repassword.value;
		if(p1!=p2){
			pwd.innerHTML="两次密码不一致";
		}else{
			pwd.innerHTML="";
		}
		
	}
	
	function validate() {
	  var msg=	document.getElementById("msg").innerText;
	  var pwd=	document.getElementById("pwd").innerText;
	  if(msg!="" || pwd !=""){
		  alert("提交前保证信息正确性！");
		  return false;
	  }
	  return true;
	}

</script>
</head>
<body>
<div id="header" class="wrap">
	<div id="logo"><img src="images/logo.gif" /></div>
</div>
<div id="regLogin" class="wrap">
	<div class="dialog">
		<dl class="clearfix">
			<dt>新用户注册</dt>
			<dd class="past">填写个人信息</dd>
		</dl>
		<div class="box">
			<form action="register" method="post" onsubmit="return validate()">
				<div class="infos">
					<table class="field">
						<tr>
							<td class="field">用 户 名：</td>
							<td><input type="text" class="text" name="name" id="name"  onblur="post()" required="required"/> <span id="msg" style="color: red;"></span> </td>
						</tr>
						<tr>
							<td class="field">密　　码：</td>
							<td><input type="password" class="text" name="password" id="password" required /></td>
						</tr>
						<tr>
							<td class="field">确认密码：</td>
							<td><input type="password" class="text" id="repassword" onblur="checkPwd()" required/> <span id="pwd" style="color: red;"></span> </td>
						    
						</tr>
						<tr>
							<td class="field">电　　话：</td>
							<td><input type="text" class="text" name="telephone" required="required" /> </td>
						</tr>
						<tr>
							<td class="field">用户姓名：</td>
							<td><input type="text" class="text" name="username"  required="required"/> </td>				
						</tr>
					</table>
					<div class="buttons"><input type="submit" name="submit" value="立即注册" /></div>
				</div>
			</form>
		</div>
	</div>
</div>
<div id="footer" class="wrap">
	<dl>
    	<dt>禾米租房 &copy; 2010 禾米教育 浙ICP证1000001号</dt>
        <dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
    </dl>
</div>
</body>
</html>

